package com.junzhiit.nengji.cms.web.controller;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.junzhiit.nengji.cms.service.SellLevelService;
import com.junzhiit.nengji.cms.web.vo.DataTablesParamVO;
import com.junzhiit.nengji.cms.web.vo.ResultVO;
import com.junzhiit.nengji.cms.web.vo.SellLevelVO;

import io.swagger.annotations.ApiOperation;

@RestController
@RequestMapping("/sell/level")
public class SellLevelController extends BaseController{

	@Autowired
	private SellLevelService sellLevelService;
	
	@ApiOperation(value = "查询所有分润信息")
	@RequestMapping(method = RequestMethod.GET)
	public Map<String, Object> findAll(DataTablesParamVO dtp,SellLevelVO sellLevelVO) {
		return sellLevelService.findAll(dtp,sellLevelVO);
	}
	
	@ApiOperation(value = "查询当前分润等级最大值")
	@RequestMapping(value="/max",method = RequestMethod.GET)
	public ResultVO findMax() {
		return sellLevelService.getBenefitMax();
	}
	
	@ApiOperation(value = "ID查询分润信息")
	@RequestMapping(value="/find",method = RequestMethod.GET)
	public ResultVO findById(String id) {
		return sellLevelService.findById(id);
	}
	
	@ApiOperation(value ="添加分润类别")
	@RequestMapping(value="/add",method = RequestMethod.POST)
	public ResultVO add(SellLevelVO sellLevelVO) {
		return sellLevelService.add(sellLevelVO);
	}
	
	@ApiOperation(value="更新分润类别")
	@RequestMapping(value="/update",method=RequestMethod.PUT)
	public ResultVO update(SellLevelVO sellLevelVO){
		return sellLevelService.update(sellLevelVO);
	}
	
	@ApiOperation(value="删除分润类别")
	@RequestMapping(value="/del",method=RequestMethod.DELETE) 
	public ResultVO delete(String id){
		return sellLevelService.delete(id);
	}
	
}
